package generics;

public class GenericsTest<T> {
    //此时x的类型并不确定，在产生这个对象时确定类型
    private T x;
    private T y;

    public T getX() {
        return x;
    }

    public void setX(T x) {
        this.x = x;
    }

    public T getY() {
        return y;
    }

    public void setY(T y) {
        this.y = y;
    }

    public static void main(String[] args) {
        //使用字符串类型
        GenericsTest<String> genericsTest=new GenericsTest<>();
        genericsTest.setX("张三");
        genericsTest.setY("小熊");
        String x=genericsTest.getX();
        String y=genericsTest.getY();
        System.out.println(x+"的小名叫"+y);

    }

}
